// 存放接口
import request from '@/utils/request.js'
import store from '@/store'

// 封装接口请求的方法
export const allChannelListAPI = () => {
  return request({
    // 请求所有频道数据
    url: '/v1_0/channels'
  })
}

// 用户登录接口
export const loginAPI = ({ mobile, code }) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
// 频道 - 用户已选列表
export const userChannelAPI = () => {
  return request({
    url: '/v1_0/user/channels',
    headers: {
      Authorization: 'Bearer ' + store.state.token
    }
  })
}
// 文章 - 获取列表
export const articlesListAPI = ({ channelId, timestamp }) => {
  return request({
    url: '/v1_0/articles',
    method: 'GET',
    params: {
      channel_id: channelId,
      timestamp: timestamp || (new Date()).getTime()
    }
  })
}
